/*  
 * Copyright 2007 MBARI 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.mbari.timeline.model;

import com.domainlanguage.time.Duration;
import com.domainlanguage.time.TimePoint;

/** 
 * @author Andrew Chase
 */
public class MultipartEvent extends Event{
	private Duration[] durations;
	private Duration summedDuration;
	
	public static MultipartEvent twoPartEvent(TimePoint time, Duration part1, Duration part2){
		MultipartEvent event = new MultipartEvent();
		event.setTime(time);
		event.setDurations(part1, part2);
		return event;
	}

	public void setDurations(Duration ... durations){
		this.durations = durations;
		summedDuration = Duration.NONE;
		for (Duration duration : durations) {
			summedDuration = summedDuration.plus(duration);
		}
	}
	
	public void setDuration(@SuppressWarnings("unused")
    Duration duration){
		throw new UnsupportedOperationException("Only setDurations is allowed on a MultipartEvent");
	}
	
	public Duration getDurationPart(int part){
		return durations[part];
	}

	public Duration getDuration() {
		return summedDuration;
	}

	public Duration[] getDurations() {
		return durations;
	}

}
